package cn.telling.tianlianApple.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import cn.telling.tianlianApple.dao.AppleProductMapper;
import cn.telling.tianlianApple.service.IAppleProductService;
import cn.telling.tianlianApple.vo.ProductCategroyVo;
import cn.telling.tianlianApple.vo.ProductOrderVo;
import cn.telling.tianlianApple.vo.SpecificationVauelVo;
import cn.telling.tianlianApple.vo.SpecificationVo;
import cn.telling.utils.StringHelperTools;
/**
 * 
 * @ClassName: AppleProductServiceImpl 
 * @Description: 苹果业务产品相关接口的实现
 * @author chxb
 * @date 2015年9月24日 下午3:49:15 
 *
 */
@Service("appleProductService")
public class AppleProductServiceImpl implements IAppleProductService {
	
	@Autowired
	@Qualifier("appleProductMapper")
	private AppleProductMapper appleProductMapper;
	
	@Override
	public List<ProductCategroyVo> queryProductCategroyData() {
		return appleProductMapper.findProductCategroyData();
	}

	@Override
	public String queryProductStock(String supplyArea0Id) {
		return appleProductMapper.findProductStock(supplyArea0Id);
	}

	@Override
	public List<SpecificationVo> queryProductSpecficationData(String sortId) {
		List<SpecificationVo> resultList= new ArrayList<SpecificationVo>();
		List<SpecificationVo> specificationList= new ArrayList<SpecificationVo>();
		specificationList = appleProductMapper.findProductSpecficationData(sortId);
		if(specificationList!=null &&specificationList.size()>0){
			for(SpecificationVo vo:specificationList){
				List<SpecificationVauelVo> valueList = new ArrayList<SpecificationVauelVo>();
				valueList=appleProductMapper.findProductSpecficationDetailData(StringHelperTools.nvl(vo.getSpecificationId()));
				vo.setValueList(valueList);
				resultList.add(vo);
			}
		}
		return resultList;
	}

	@Override
	public ProductOrderVo queryByShopProductId(String supplyArea0Id) {
		ProductOrderVo productOrderVo = appleProductMapper.findByShopProductId(supplyArea0Id);
		return productOrderVo;
	}

}
